{include file="layout/layout" /}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>广告列表</h3>
                <h5>广告索引与管理</h5>
                <ul class="tab-base nc-row">
                    {foreach $ty_list as $k=>$v}
                    <li><a href="{:url('Ad/adlist',['inc_type'=> $k])}" {if condition="$k eq $inc_type"}class="current"{/if}><span>{$v}</span></a></li>
                    {/foreach}
                </ul>
            </div>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li>预览广告时只需要点击图片即可查看大图，点击非图片区域即可关闭.</li>
            <li>无特殊情况请勿停止正在播放的广告.</li>
        </ul>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>广告列表</h3>
                <h5>(共{$adcount}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline"  id="search-form2" onsubmit="return false">
                <input type="hidden" name="order_by" value="user_id">
                <input type="hidden" name="sort" value="desc">
                <input type="hidden" name="mobile" value="" id="input-mobile" />
                <input type="hidden" name="email" value="" id="input-email" />
                <!--分销时查看下级人数都有哪些-->
                <input type="hidden" name="first_leader" value="">
                <input type="hidden" name="second_leader" value="">
                <input type="hidden" name="third_leader" value="">
                <!--搜索-->
                <!-- <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" id="search_key" size="30" class="qsbox" placeholder="手机或者邮箱...">
                        <input type="submit" class="btn" onclick="ajax_get_table('search-form2',1)" value="搜索">
                    </div>
                </div> -->
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th class="sign" axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" abbr="user_id" axis="col3" class="">
                            <div style="text-align: center; width: 50px;" class="">广告id</div>
                        </th>
                        <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 100px;" class="">发布商户</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 100px;" class="">审核代理商</div>
                        </th>
                        <th align="left" abbr="nickname" axis="col4" class="">
                            <div style="text-align: center; width: 100px;" class="">广告位置</div>
                        </th>
                        <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 150px;" class="">广告内容</div>
                        </th>
                        <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 150px;" class="">广告描述</div>
                        </th>
                        <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 100px;" class="">跳转链接</div>
                        </th>
                        <th align="center" abbr="total_amount" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">开始时间</div>
                        </th>
                        <th align="center" abbr="email" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">结束时间</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 100px;" class="">状态</div>
                        </th>
                         <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 140px;" class="">操作</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton">
                    <a href="addAds?label=1">
                        <div class="add" title="添加默认广告">
                            <span><i class="fa fa-plus"></i>添加默认广告</span>
                        </div>
                    </a>
                </div>
            </div>
            <div style="clear:both"></div>
        </div>
         <div class="bDiv" style="height: auto;" id="ajax_return"><div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
    <table>
        <tbody>
            {foreach $adlist as $v}
            <tr data-id="2592" id='del{$v.ad_id}'>
                <td class="sign">
                    <div style="width: 24px;"><i class="ico-check"></i></div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 50px;">{$v.ad_id}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 100px;">{$v.sp_name}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 100px;">{$v.agem_number}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 100px;">{$v.ad_label}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 150px;">
                        {if $v['ad_mart']=='文字'}{$v.ad_content}
                        {elseif $v['ad_mart']=='图片' /}<center><img onclick="showBigImg(this)" src="__ROOT__{$v.ad_image_url}" style="width: 50px;" /></center>
                        {/if}
                    </div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 150px;">{$v.ad_desc}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 100px;">{$v.ad_url}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 120px;">{$v.ad_start_time}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 120px;">{$v.ad_end_time}</div>
                </td>
                <td class="" align="left">
                    <div style="text-align: center; width: 100px;">{$v.ad_status}</div>
                </td>
                <td class="" align="center">
                    <div style="text-align: center; width: 200px;">
                        {if $v['ad_status'] == '正在播放' }<a class="btn blue" onclick="return firm({$v.ad_id},1)" href="JavaScript:void(0);"><i class="fa fa-pencil-square-o"></i>停止播放</a>
                        {elseif $v['ad_status'] == '已播出' /}<span class="btn blue" >已审核</span>
                        {elseif $v['ad_status'] == '已审核未播' /}<span class="btn blue" >已审核</span>
                        {elseif $v['ad_status'] == '未审核未播' /}<a class="btn blue" onclick="return firm({$v.ad_id},2)" href="JavaScript:void(0);"><i class="fa fa-check"></i>通过</a>
                                                                  <a class="btn blue" onclick="return firm({$v.ad_id},3)" href="JavaScript:void(0);"><i class="fa fa-ban"></i>未通过</a>
                        {else $v['ad_status'] == '未通过审核'/}<span class="btn blue" >已审核</span>
                        {/if}
                        <!-- 1正在播放2已播出,3已审核未播,4未审核未播,5未通过审核 -->
                        {if $v['ad_shop_id']==0 && $v['ad_agents_id']==0}<a class="btn red" onclick="del({$v.ad_id})" href="JavaScript:void(0);"><i class="fa fa-trash-o"></i>删除默认</a>{/if}
                    </div>
                </td>
                <td class="" style="width: 100%;" align="">
                    <div>&nbsp;</div>
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
</div>
<!--分页位置-->
<center>{$adlist->render()|raw}</center>
</div>
</div>
</body>
</html>
<script type="text/javascript">
    function conf(con, adid, info, al1, al2, al3){
        layer.confirm(con, {
              btn: ['确定','取消'] //按钮
            }, function(){
                // 确定
                $.get("{:url('admin/Ad/stop')}",{'id': adid, 'info': info},function(data){
                    if(data == 1){
                        layer.msg(al1, {time: 2000}, function(){
                            window.location.reload();
                        });
                    }else{
                        layer.msg(al2, {time: 2000});
                    }
                });
            }, function(index){
                layer.close(index);
                layer.msg(al3, {time: 2000});
            }
        );
    }
    function firm(adid, info){
        if(info == 1){
            conf("确定停止播放吗?", adid, info, "停止播放成功", "停止播放失败,请稍后重试!", "停止播放已取消");
            return false;
        }
        if(info == 2){
            conf("确定通过审核吗?", adid, info, "通过审核已成功", "通过审核失败,请稍后重试!", "通过审核已取消");
            return false;
        }
        if(info == 3){
            conf("确定未通过审核吗?", adid, info, "未通过审核已成功", "未通过审核失败,请稍后重试!", "未通过审核已取消");
            return false;
        }
    }
    function showBigImg(obj){
        var objurl = $(obj).attr('src');
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '700px',
            skin: 'layui-layer-nobg',
            shadeClose: true,
            content: "<img src="+objurl+" width='700px'/>"
        });
    }

    // 删除广告
    function del(id){
        if(confirm('删除后不能恢复，确认要删除该广告吗？')){
            $.get('delAjax',{'id':id},function(data){
                if(data == 1){
                    $('#del'+id).remove();
                    alert('删除成功！');
                }else{
                    alert('删除失败！');
                }
            })
        }else{
            return false;
        }
    }
</script>